<?php
require_once(OC::$SERVERROOT . "/apps/jobposition/lib/helper.php");
require_once(OC::$SERVERROOT . "/apps/resumes/lib/helper.php");

$isMasterUser = PFactory::isMasterUser();
$sysFolderNum = $isMasterUser ? 1 : 3;
$folder_limit = 10 - $sysFolderNum + 1;
$customFolders = PJobpositionHelper::getCustomFolderList('', $folder_limit);
$searchUrl = OC_Helper::linkToRoute('jobpos_folder');
?>

<?php if(PCompanyHelper::isJobManager() && !$isMasterUser): ?>
<div><a href="<?php echo OC_Helper::linkToRoute('jobpos_folder', array('jobdir' => 'subcompany'));?>" >公司职位</a></div>
<?php endif; ?>
<div><a href="<?php echo OC_Helper::linkToRoute('jobpos_folder', array('jobdir' => 'trashed'));?>" >回收站</a></div>
<?php 
$checkMoreFoldersHtml = '';
if (!empty($customFolders)) {
   $i=0;
   foreach ($customFolders as $customFolder) {
      if ($i == $folder_limit - 1) {
         $checkMoreFoldersHtml = '<div class="last_lookmore showlist"><a href="javascript:;">查看更多...</a></div>';
         break;
      }
      list($href, $selected) = PResumesHelper::getSearchItemHref($searchUrl, 'jobdir', $customFolder->folder_id);
      if (!empty($customFolder->folder_name))
         list($href, $selected) = PResumesHelper::getSearchItemHref($href, 'foldername', rawurlencode($customFolder->folder_name));
?>
<div class="canedit clearfix" data-fid="<?=$customFolder->folder_id?>">
   <a href="<?=$href?>"><?=$customFolder->folder_name?><em style="color:#666666;">(<?=$customFolder->num?>)</em></a>
   <input class="fname" style="display:none;" type="text" value="<?=$customFolder->folder_name?>"/>
   <div class="editbtns hide"><i class="ok"></i> <i class="cancel"></i></div>
   <div class="btns hide"><i class="editi"></i> <i class="closei"></i></div>
</div>
<?php
      $i++;
   }
}
?>
<div class="last_lookmore" id="createfolder_btn"><a href="javascript:;">创建文件夹 <i class="addi"></i></a></div>
<?php echo $checkMoreFoldersHtml ? $checkMoreFoldersHtml : '';?>